/**
 * 
 */
package org.mhz.sit.util;

import javafx.animation.FadeTransition;
import javafx.collections.ObservableList;
import javafx.scene.image.ImageView;
import javafx.util.Duration;

import org.mhz.sit.entity.Speaker;
import org.mhz.sit.entity.SpeakerOffTopicOrder;
import org.mhz.sit.entity.SpeakerOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Mahan
 *
 * Speaker utility class
 */
public final class SpeakerUtil
{
    private static final Logger LOGGER = LoggerFactory.getLogger(SpeakerUtil.class);
    
    private static ObservableList<Speaker> observableSpeakerList = null;
    private static ObservableList<SpeakerOrder> observableOrderOfSpeakersList = null;
    private static ObservableList<SpeakerOffTopicOrder> observableOffTopicOrderList = null;
    
    private static SpeakerOrder currentSpeaker = null;
    
    /**
     * Private constructor
     */
    private SpeakerUtil()
    {
        
    }

    /**
     * @return Returns the observableSpeakerList.
     */
    public static ObservableList<Speaker> getObservableSpeakerList()
    {
        return observableSpeakerList;
    }

    /**
     * @param aObservableSpeakerList The observableSpeakerList to set.
     */
    public static void setObservableSpeakerList(
            final ObservableList<Speaker> aObservableSpeakerList)
    {
        observableSpeakerList = aObservableSpeakerList;
    }

    /**
     * @return Returns the observableOrderOfSpeakersList.
     */
    public static ObservableList<SpeakerOrder> getObservableOrderOfSpeakersList()
    {
        return observableOrderOfSpeakersList;
    }

    /**
     * @param aObservableOrderOfSpeakersList The observableOrderOfSpeakersList to set.
     */
    public static void setObservableOrderOfSpeakersList(
            final ObservableList<SpeakerOrder> aObservableOrderOfSpeakersList)
    {
        observableOrderOfSpeakersList = aObservableOrderOfSpeakersList;
    }

    /**
     * @return Returns the observableOffTopicOrderList.
     */
    public static ObservableList<SpeakerOffTopicOrder> getObservableOffTopicOrderList()
    {
        return observableOffTopicOrderList;
    }

    /**
     * @param aObservableOffTopicOrderList The observableOffTopicOrderList to set.
     */
    public static void setObservableOffTopicOrderList(
            final ObservableList<SpeakerOffTopicOrder> aObservableOffTopicOrderList)
    {
        observableOffTopicOrderList = aObservableOffTopicOrderList;
    }       
    
    /**
     * @return Returns the currentSpeaker.
     */
    public static SpeakerOrder getCurrentSpeaker()
    {
        return currentSpeaker;
    }

    /**
     * @param aCurrentSpeaker The currentSpeaker to set.
     */
    public static void setCurrentSpeaker(final SpeakerOrder aCurrentSpeaker)
    {
        currentSpeaker = aCurrentSpeaker;
    }

    /**
     * Fade out image
     *
     * @param aImageView - The image to fade
     */
    public static void fadeOutImage(final ImageView aImageView)
    {
        final FadeTransition fadeOutTransition = new FadeTransition(Duration.millis(Constants.FADE_DURATION), aImageView);        
        fadeOutTransition.setFromValue(Constants.FULL_OPACITY);
        fadeOutTransition.setToValue(Constants.NO_OPACITY);
        fadeOutTransition.play();        
    }
    
    /**
     * Fade in image
     *
     * @param aImageView - The image to fade
     */
    public static void fadeInImage(final ImageView aImageView)
    {
        final FadeTransition fadeInTransition = new FadeTransition(Duration.millis(Constants.FADE_DURATION), aImageView);        
        fadeInTransition.setFromValue(Constants.NO_OPACITY);
        fadeInTransition.setToValue(Constants.FULL_OPACITY);
        fadeInTransition.play();
    }
}
